package org.baizhiedu.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * ClassName: MyAspect
 * Description:
 * 1.额外功能
 * public class MyAround implements MethodInterceptor {
 * public Object invoke(MethodInvocation invocation){
 * Object ret = invocation.proceed();
 * return ret;
 * }
 * }
 * 2.切入点
 * <aop:config>
 * <aop:pointcut id="" expression="execution(* login(..))"/>
 * </aop:config>
 * Date: 2022/11/23 AM 10:52:29
 * <p>
 * project: spring5
 * package: org.baizhiedu.aspect
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
@Aspect
public class MyAspect {

    /**
     * 切入点复用：在切面类中定义一个函数，上面 @Pointcut 注解，通过这种方式，定义切入点表达式，后续更加有利于切入点复用
     */
    @Pointcut("execution(* *..UserServiceImpl.*(..))")
    public void myPointcut() {

    }

    @Around(value = "myPointcut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("---aspect log---");
        return joinPoint.proceed();
    }

    @Around(value = "myPointcut()")
    public Object around1(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("---aspect tx---");
        return joinPoint.proceed();
    }
}
